/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

export type TypeLoginPageTypes =
  | 'city'
  | 'wdadmin'
  | 'courier'
  | 'kbyz'
  | 'zy'
  | 'yjy'
  | 'jdk'
  | 'jdkjms'
  | 'jdkweb'
  | 'vhome_web'
  | 'vhome'
  | 'jdklss'
  | 'jdk_rider'
  | 'jdk_fn';

interface TabListItem {
  key: TypeLoginPageTypes;
  tab: string;
  pwd?: boolean;
}

export interface TypeLoginPage {
  type: TypeLoginPageTypes;
  activeKey: string;
  name: string;
}

export const tabList: TabListItem[] = [
  {
    tab: '新零售平台',
    key: 'city',
  },
  {
    tab: '网点后台',
    key: 'wdadmin',
  },
  {
    tab: '快递员APP',
    key: 'courier',
    pwd: true,
  },
  {
    tab: '快宝驿站APP',
    key: 'kbyz',
    pwd: true,
  },
  {
    tab: '中邮共配',
    key: 'zy',
  },
  {
    tab: '驿加易',
    key: 'yjy',
  },
  {
    tab: '聚单客APP',
    key: 'jdk',
    pwd: true,
  },
  {
    tab: '聚单客加盟商',
    key: 'jdkjms',
  },
  {
    tab: '聚单客网页版',
    key: 'jdkweb',
  },
  {
    tab: '微掌柜网页版',
    key: 'vhome_web',
  },
  {
    tab: '微掌柜APP',
    key: 'vhome',
    pwd: true,
  },
  {
    tab: '聚单客连锁商',
    key: 'jdklss',
  },
  {
    tab: '飓风快跑',
    key: 'jdk_rider',
    pwd: true,
  },
  {
    tab: '蜂鸟校园',
    key: 'jdk_fn',
  },
];

export const openLink = (url: string) => {
  const u = navigator.userAgent;
  const isIos = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  if (isIos) {
    window.location.href = url;
  } else {
    window.open(url);
  }
};
